package com.zshan.clinic.common.enums;


import com.zshan.clinic.common.util.string.StringUtil;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 挂号状态
 */
public enum RegStatusEnum {

    /**
     * 预约成功未取号
     */
    RESERVED("1", "待取"),

    /**
     * TODO 兼容后边有加了签到机的场景，已取号待签到
     */
    PAID_NOT_TAKEN("2", "待签"),

    /**
     * 已签到待看诊
     */
    CHECK_IN("3", "待诊"),
    COMPLETED("5", "已诊"),
    REFUNDED("6", "已退"),
    /**
     * 已过期未取号
     */
    EXPIRED("7", "过期");

    /**
     * 生效中的状态
     * @return
     */
    public static List<String> getActiveList(){
        List<String> reserveList = new ArrayList<>();
        reserveList.add(RESERVED.getValue());
        reserveList.add(PAID_NOT_TAKEN.getValue());
        reserveList.add(CHECK_IN.getValue());
//        reserveList.add(IN_TREATMENT.getValue());
        return reserveList;
    }

    public static List<String> getReserveList(){
        List<String> reserveList = new ArrayList<>();
        reserveList.add(RESERVED.getValue());
        reserveList.add(PAID_NOT_TAKEN.getValue());
        reserveList.add(CHECK_IN.getValue());
//        reserveList.add(IN_TREATMENT.getValue());
        reserveList.add(COMPLETED.getValue());
        return reserveList;
    }

    /**
     * 检查挂号的状态是否能退
     * @param regStatus
     * @return
     */
    public static boolean canRefund(String regStatus){
        if(RESERVED.getValue().equals(regStatus)
                || PAID_NOT_TAKEN.getValue().equals(regStatus)
                || CHECK_IN.getValue().equals(regStatus)){
            return true;
        }
        return false;
    }

    private String value;
    private String text;

    private RegStatusEnum(String value, String text) {
        this.value = value;
        this.text = text;
    }

    public String getValue() {
        return this.value;
    }

    public String getText() {
        return this.text;
    }

    public static RegStatusEnum getValue(String value) {
        if(StringUtil.isBlank(value)){
            return null;
        }
        RegStatusEnum[] arr$ = values();
        int len$ = arr$.length;
        for(int i$ = 0; i$ < len$; ++i$) {
            RegStatusEnum dot = arr$[i$];
            if (value.equals(dot.getValue())) {
                return dot;
            }
        }
        return null;
    }

    public static String getText(String value) {
        if(StringUtil.isBlank(value)){
            return null;
        }
        RegStatusEnum[] arr$ = values();
        int len$ = arr$.length;
        for(int i$ = 0; i$ < len$; ++i$) {
            RegStatusEnum dot = arr$[i$];
            if (value.equals(dot.getValue())) {
                return dot.getText();
            }
        }
        return null;
    }

    public static boolean isValue(String value) {
        if(StringUtil.isBlank(value)){
            return false;
        }
        RegStatusEnum[] arr$ = values();
        int len$ = arr$.length;
        for(int i$ = 0; i$ < len$; ++i$) {
            RegStatusEnum dot = arr$[i$];
            if (value.equals(dot.getValue())) {
                return true;
            }
        }
        return false;
    }

    public Map toMap() {
        Map map = new HashMap();
        map.put("value", this.value);
        map.put("text", this.text);
        return map;
    }

    public static List<Map> allToMap() {
        List<Map> list = new ArrayList();
        RegStatusEnum[] arr$ = values();
        int len$ = arr$.length;
        for(int i$ = 0; i$ < len$; ++i$) {
            RegStatusEnum dot = arr$[i$];
            list.add(dot.toMap());
        }
        return list;
    }
}
